﻿<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Gramos - 管理员</title>

    <!-- begin::global styles -->
    <link rel="stylesheet" href="assets/vendors/bundle.css" type="text/css">
    <!-- end::global styles -->

    <!-- begin::custom styles -->
    <link rel="stylesheet" href="assets/css/app.css" type="text/css">
    <!-- end::custom styles -->

</head>
<body class="bg-white h-100-vh p-t-0">

<!-- begin::page loader-->
<div class="page-loader">
    <div class="spinner-border"></div>
    <span>Loading ...</span>
</div>
<!-- end::page loader -->

<div class="p-b-50 d-block d-lg-none"></div>

<div class="container h-100-vh">
    <div class="row align-items-md-center h-100-vh">
        <div class="col-lg-6 d-none d-lg-block">
            <img class="img-fluid" src="assets/media/svg/login.svg" alt="...">
        </div>
        <div class="col-lg-4 offset-lg-1">
            <div class="d-flex align-items-center m-b-20">
                <img src="assets/media/image/dark-logo.png" class="m-r-15" width="40" alt="">
                <h3 class="m-0">Gramos 管理员</h3>
            </div>

            <!--            登录表单-->
            <p>正在登录...</p>
            <form id="loginUser">

                <!--               表单主要内容-->
                <!--         用户名       -->
                <div class="form-group mb-4">
                    <input type="text" name="name" class="form-control form-control-lg" id="loginname"
                           autofocus placeholder="用户名">
                </div>
                <!--         密码       -->
                <div class="form-group mb-4">
                    <input type="password" name="password" class="form-control form-control-lg"
                           id="exampleInputPassword1" placeholder="密码">
                </div>
                <!--         登录按钮       -->
                <button type="button" onclick="doLogin()" class="btn btn-primary btn-lg btn-block btn-uppercase mb-4">
                    登录
                </button>
                <h3 style="color:red;" id="errMessage"></h3>
                <!--               表单主要内容 -->

                <div class="d-flex justify-content-between align-items-center mb-4">
                    <div class="custom-control custom-checkbox">
                        <input type="checkbox" class="custom-control-input" id="customCheck">
                        <label class="custom-control-label" for="customCheck">自动登录</label>
                    </div>
                    <a href="recover-password" class="auth-link text-black">忘记密码？</a>
                </div>

                <!--         跳转到注册页面/表单       -->
                <div class="text-center">
                    没有账号? <a href="register" class="text-primary">创建一个</a>
                </div>
            </form>
            <!--            登录表单-->
        </div>
    </div>
</div>

<!-- begin::global scripts -->
<script src="assets/vendors/bundle.js"></script>
<!-- end::global scripts -->

<!-- begin::custom scripts -->
<script src="assets/js/app.js"></script>
<!-- end::custom scripts -->

<!-- begin::pagestotransmitdata scripts -->
<script src="assets/js/pagestotransmitdata.js"></script>
<!-- end::pagestotransmitdata scripts -->

<!--开始：登录的处理函数-->
<script>

    function doLogin() {
        //1、获取登录表单所需要提交的数据
        var data = $('#loginUser').serializeArray();
        // console.log(data);//打印数据
        //2、通过ajax函数提交异步请求 ajax() post() get()
        // 1\url 2\data【入参的数据】 3\回调函数【请求成功之后的处理方法】
        $.post('dologin', data, function (result) {//result就是data入参后的数据所得到的结果
            //3、请求成功之后，根据响应的结果来进行操作处理（登录失败/登录成功）
            if (result.isok == true) {//登录成功
                alert(result.message);
                location.href = 'index';
            } else {//登录失败
                alert(result.error);
            }

        });


    }
</script>
<!--结束：登录的处理函数-->

</body>
</html>
